package chat.client.resources;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DownloadPanel.java
 *
 * Created on Apr 1, 2010, 2:09:51 AM
 */
import java.lang.*;
import java.net.*;
import java.io.*;
import java.util.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import javax.swing.*;
import chat.client.resources.*;

/**
 *
 * @author seb
 */
public class DownloadPanel extends JPanel implements ListSelectionListener {

    private JList jList;
    private JScrollPane scrollPane;
    private Vector<ProgressBar> vectProgressBar = new Vector();

    /** Creates new form DownloadPanel */
    public DownloadPanel() {
        super(new BorderLayout());
        initComponents();
        jList = new JList();
        JListRenderer renderer = new JListRenderer();
        jList.setCellRenderer(renderer);
        
        jList.addListSelectionListener(this);
        scrollPane = new JScrollPane(jList);
        add(scrollPane, BorderLayout.CENTER);
    }

    public void addPB(ProgressBar e) {
        vectProgressBar.add(e);
        System.out.println(" hello !");
        this.remove(scrollPane);
        jList = new JList(vectProgressBar);

        JListRenderer renderer = new JListRenderer();
        jList.setCellRenderer(renderer);

        jList.addListSelectionListener(this);

        scrollPane.removeAll();
        scrollPane = new JScrollPane(jList);

        add(scrollPane, BorderLayout.CENTER);

        this.revalidate();
        this.repaint();
    }

    public void valueChanged(ListSelectionEvent e) {
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setLayout(new java.awt.BorderLayout());
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}

class JListRenderer implements ListCellRenderer {

    public Component component;

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        component = (Component) value;
        if (isSelected) {
        }
        return component;
    }
}
